Concept exceptions are very similar with the C++ exceptions, the only difference is the fact that they don’t belong to a variable type. In a try-catch statement you will have only one type of catch (instead of one or more in C++)
Another difference is that an uncaught exception, it will be caught by the Concept machine automatically, and retrown for the calling function like this:
The syntax for throw is:
throw expr;
expr can be any kind of variable or expression.
Example
function B() {
throw “Exception !!!”;
}
function A() {
// no try/catch !!! in C++ this will cause the program to fail.
// in this case, the uncaught exception will cause the sudden termination of A
// and A will re-throw the exception raised by B
B();
}
function C() {
try {
A();
} catch (var Exception) { // will catch the exception raised by B and not catched by A
echo Exception;
}
}